package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"time"
)

type monitor struct {
	Status string `default:"Server is OK." json:""`
	Time   string `json:""`

	OnlineUserCount int64 `default:"0" json:""`
	ActiveConnCount int64 `default:"0" json:""`

	DAU            int64 `default:"0" json:""`
	TotalConnToday int64 `default:"0" json:""`
	TotalMsgToday  int64 `default:"0" json:""`
}

func (t *monitor) testlive(rw http.ResponseWriter, req *http.Request) error {
	t.Status = "Server is OK."
	t.Time = time.Now().String()

	jsons, errs := json.Marshal(t)
	if errs != nil {
		return errs
	}

	fmt.Fprintf(rw, string(jsons))
	return nil
}
